using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;
using UnityEngine;
using UnityEngine.Pool;
using UnityEngine.SceneManagement;
using static UnityEditor.Progress;

public class CharacterSkillManager 
{
    private List<SkillData> items = new List<SkillData>();
    SkillData Read(JObject jarray)
    {
        int Id = (int)jarray["SkillId"];
        string Name = (string)jarray["Name"];
        string description = (string)jarray["Description"];
        int SkillCd = (int)jarray["SkillCd"];
        string path=(string)jarray["Path"];
        SkillData item = new SkillData(Id, Name, description, SkillCd, path);
        return item;
    }
    public void ToJoson()
    {
        TextAsset Text = Resources.Load<TextAsset>("Text/Item");
        string json = Text.text;

        JArray jArray = JArray.Parse(json);
        foreach (JObject jarray in jArray)
        {
            SkillData item = Read(jarray);
            items.Add(item);
        }
    }
    public SkillData ReturnSkill(string playername)
    {
        Debug.Log(items);
        foreach (var item in items)
        {
            if(item.playername==playername)
            {
                SkillData skilldate = new SkillData(item.skillId, item.playername, item.description, item.skillCd,item.imagepath);
                return skilldate;
            }
        }
        return null;
    }
}
